<template>
    <div class="container">
        <ul>
            <li>【摸鱼办】提醒您：今天是{{moyu.date}},星期{{moyu.week}}，大家好。工作再累，一定不要忘记休息哦！起身去茶水间，去厕所，去廊道走走活动一下身体，祝愿所有朋友们，都能愉快的度过每一天…</li>
             <li>距离【周末】还有:{{moyu.weeks}}天</li>
            <li>距离【中秋】还有:{{moyu.zhongqiu}}天</li>
            <li>距离【国庆】还有:{{moyu.guoqing}}天</li>
            <li>距离【元旦】还有:{{moyu.yuandan}}天</li>
            <li>距离【春节】还有:{{moyu.chunjie}}天</li>
            <li>Growth is about facing human nature countless times and then facing it calmly.</li>
            <li>成长就是无数次直视人性，然后坦然面对</li>
        </ul>
    </div>
</template>
<script setup lang="ts">
interface typeData {
    date:string,
    week:number,
    weeks:number,
    zhongqiu:number,
    guoqing:number,
    yuandan:number,
    chunjie:number,
    daysBetweenDates:Function,
    getDate:Function
}

const moyu:typeData = reactive({
    date:'',
    week:0,
    weeks:0,
    zhongqiu:0,
    guoqing:0,
    yuandan:0,
    chunjie:0,
    daysBetweenDates(date1:Date, date2:Date){
        const oneDay = 24 * 60 * 60 * 1000;
        return Math.abs(Math.round((date1.valueOf() - date2.valueOf()) / oneDay));
    },
    getDate(){
        const currentDate = new Date();
        const currentYear = currentDate.getFullYear();
        const currentMonth = currentDate.getMonth() + 1;
        const currentDay = currentDate.getDate();
        const currentDayOfWeek = currentDate.getDay(); // 0 表示周日，1 表示周一，以此类推

        // 计算距离本周六的天数
        const daysUntilSaturday = currentDayOfWeek !== 6 ? 6 - currentDayOfWeek : 0;

        // 计算距离中秋的时间（假设中秋节固定在9月15日）
        const midAutumnDate = new Date(currentYear, 8, 29); // 月份从0开始，所以这里是8
        const daysUntilMidAutumn = moyu.daysBetweenDates(midAutumnDate, currentDate);

        // 计算距离国庆的时间（假设国庆节固定在10月1日）
        const nationalDayDate = new Date(currentYear, 9, 1); // 月份从0开始，所以这里是9
        const daysUntilNationalDay = moyu.daysBetweenDates(nationalDayDate, currentDate);

        // 计算距离元旦的时间
        const newYearDate = new Date(currentYear + 1, 0, 1);
        const daysUntilNewYear = moyu.daysBetweenDates(newYearDate, currentDate);

        // 计算距离春季的时间（假设春季开始于3月1日）
        const springStartDate = new Date(currentYear + 1, 1, 10); // 月份从0开始，所以这里是2
        const daysUntilSpring = moyu.daysBetweenDates(springStartDate, currentDate);

        console.log(`当前日期：${currentYear}-${currentMonth}-${currentDay}`);
        console.log(`当前周几：${currentDayOfWeek}`);
        console.log(`距离本周六还有：${daysUntilSaturday} 天`);
        console.log(`距离中秋还有：${daysUntilMidAutumn} 天`);
        console.log(`距离国庆还有：${daysUntilNationalDay} 天`);
        console.log(`距离元旦还有：${daysUntilNewYear} 天`);
        console.log(`距离春季还有：${daysUntilSpring} 天`);
        moyu.date = `${currentYear}-${currentMonth}-${currentDay}`
        moyu.week = currentDayOfWeek
        moyu.weeks = daysUntilSaturday
        moyu.zhongqiu = daysUntilMidAutumn
        moyu.guoqing = daysUntilNationalDay
        moyu.yuandan = daysUntilNewYear
        moyu.chunjie = daysUntilSpring
    }
})

onMounted(() => {
    moyu.getDate()
})
</script>
<style scoped lang="less">
.container{
    ul{
        display: table;
        margin: 50px auto 0;
    }
}


</style>